package com.modifiertech.lineage.handler;

import com.modifiertech.lineage.Lineage;
import com.modifiertech.lineage.api.PlayerData;
import com.modifiertech.lineage.event.SkillLevelUpEvent;
import com.modifiertech.lineage.event.SkillShortCutBindEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.MinecraftForge;

/**
 * @description: default
 * @author: saliencemn
 * @mail: hackingmu@outlook.com
 * @date: 2024/8/18 22:39
 */
public class SkillShortCutBindHandler {
    //饿汉
    public static SkillShortCutBindHandler INSTANCE=new SkillShortCutBindHandler();
    private SkillShortCutBindHandler(){
    }

    /**实现 技能绑定快捷键NBT数据挂载
     *
     * @param entityPlayer
     * @param skillName
     * @param skillShortCutIndex
     * @param data
     */
    public void skillShortCutBind(EntityPlayer entityPlayer, String skillName, int skillShortCutIndex, PlayerData data){
        MinecraftForge.EVENT_BUS.post(new SkillShortCutBindEvent.Pre(entityPlayer,skillName,skillShortCutIndex));
        boolean status = false;
        status = data.optSkillShortCutBind(skillName,skillShortCutIndex);
        if (status){
            data.saveAndSync();
            MinecraftForge.EVENT_BUS.post(new SkillShortCutBindEvent.Post(entityPlayer,skillName,skillShortCutIndex));
        }else{
            MinecraftForge.EVENT_BUS.post(new SkillShortCutBindEvent.PostErr(entityPlayer,skillName,skillShortCutIndex));
        }
    }

}
